package com.yhs.best;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.Toast;

public class GuideChooser extends Activity {
	int r, p, c;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.guidechooser);
		r = 0;
		p = 0;
		c = 0;
		
		TabHost tabHost=(TabHost)findViewById(R.id.tabHost);
		tabHost.setup();

		TabSpec spec1=tabHost.newTabSpec("Raid");
		spec1.setIndicator("Raid");
		spec1.setContent(R.id.traid);


		TabSpec spec2=tabHost.newTabSpec("Profession");
		spec2.setIndicator("Profession");
		spec2.setContent(R.id.tprofession);

		TabSpec spec3=tabHost.newTabSpec("Classi");
		spec3.setIndicator("Classi");
		spec3.setContent(R.id.tclassi);

		tabHost.addTab(spec1);
		tabHost.addTab(spec2);
		tabHost.addTab(spec3);
		
		Spinner sraid = (Spinner)findViewById(R.id.raidspinner);
		ArrayAdapter<CharSequence> radapter = ArrayAdapter.createFromResource(
        		this, R.array.raid_array, android.R.layout.simple_spinner_item);
        sraid.setAdapter(radapter);

        sraid.setOnItemSelectedListener(new OnItemSelectedListener() {
        	public void onItemSelected(AdapterView<?> adapter, View view,int pos, long id) {
        		r = pos; 
        	}
        	public void onNothingSelected(AdapterView<?> arg0) {}
		});
        
        Button select = (Button) findViewById(R.id.bgselect);
        select.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent raidguidelaunch = new Intent("com.yhs.best.GUIDERAID");
				Bundle bundle = new Bundle();
				bundle.putInt("pagine", pagecounter(r));
				bundle.putInt("raid", r);
				raidguidelaunch.putExtras(bundle);
				startActivity(raidguidelaunch);
			}		});
		}
		
	
	
	
	public int pagecounter (int selected){
		int pagine = 0;
		
		switch(selected){
		case 0:
			pagine = 0; //CHAMBER OF THE ASPECT
			break;
		case 1:
			pagine = 12; //ICC
			break;
		case 2:
			pagine = 15; //NAXRAMASS
			break;
		case 3:
			pagine = 1; //ONIXIA
			break;		
		case 4:
			pagine = 7; //TOC
			break;
		case 5:
			pagine = 1; //THE NEXUS
			break;
		case 6:
			pagine = 14; //ULDUAR
			break;
		case 7:
			pagine = 4; //VOA
			break;
		}				
		return(pagine);
	}


}